<?php

namespace july\julyadmin\builder;

use july\julyadmin\common\model\Config;

class Builder
{
    /**
     * 渲染顶部
     * @param $is_iframe            是否iframe
     * @param string $otherHTML     其他渲染内容
     */
    public function renderTop($is_iframe = false, $otherHTML = '')
    {
        $html = '';
        $html .= '<!DOCTYPE html>
            <html lang="zh">

            <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                <meta http-equiv="X-UA-Compatible" content="IE=edge">
                <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
                <title>' . Config::config("System.admin_name") . '</title>
                <link rel="shortcut icon" type="image/x-icon" href="/static/assets/admin/favicon.ico">
                <meta name="apple-mobile-web-app-capable" content="yes">
                <meta name="apple-touch-fullscreen" content="yes">
                <meta name="apple-mobile-web-app-status-bar-style" content="default">';
        $html .= <<<EOT

                <!-- 引入 layui.css -->
                <link href="/static/assets/admin/js/layui/css/layui.css" rel="stylesheet">
                <link href="/static/assets/admin/js/layui/css/mystyle.css" rel="stylesheet">
                <!-- 引入 layui.js -->
                <script src="/static/assets/admin/js/layui/layui.js"></script>

                <!-- 引入 jquery.js -->
                <script type="text/javascript" src="/static/assets/admin/js/jquery.min.js"></script>

                <!-- 引入 select2.css -->
                <link href="/static/assets/admin/js/select2/select2.min.css" rel="stylesheet">
                <link href="/static/assets/admin/js/select2/mystyle.css" rel="stylesheet">

                <!-- 引入 select2.js -->
                <script src="/static/assets/admin/js/select2/select2.min.js"></script>
                <script src="/static/assets/admin/js/select2/i18n/zh-CN.js"></script>

                <!-- 引入 jquery-validate.js -->
                <script src="/static/assets/admin/js/jquery-validate/jquery.validate.min.js"></script>
                <script src="/static/assets/admin/js/jquery-validate/messages_zh.min.js"></script>

                <!--上传插件css-->
                <link type="text/css" rel="stylesheet" href="/static/assets/admin/js/webuploader/webuploader.css">
                <script type="text/javascript" src="/static/assets/admin/js/webuploader/webuploader.js"></script>

                <!--灯箱效果插件-->
                <script type="text/javascript" src="/static/assets/admin/js/magnific-popup/magnific-popup.min.js"></script>
                <link type="text/css" rel="stylesheet" href="/static/assets/admin/js/magnific-popup/magnific-popup.min.css">

                <!--引入公共js方法js文件-->
                <script type="text/javascript" src="/static/assets/admin/js/function.js"></script>

                <link rel="stylesheet" type="text/css" href="/static/assets/admin/css/materialdesignicons.min.css">
                <link rel="stylesheet" type="text/css" href="/static/assets/admin/css/bootstrap.min.css">
                <link rel="stylesheet" type="text/css" href="/static/assets/admin/css/animate.min.css">
                <link rel="stylesheet" type="text/css" href="/static/assets/admin/js/bootstrap-multitabs/multitabs.min.css">
                <link rel="stylesheet" type="text/css" href="/static/assets/admin/css/style.min.css">
                <link rel="stylesheet" type="text/css" href="/static/assets/admin/css/mystyle.css">

                {$otherHTML}

EOT;
        $html .= '</head>
            <body' . (!$is_iframe ? ' class="lyear-index"' : '') . '>';

        echo $html;
    }

    /**
     * 渲染底部
     * @param string $otherHTML     其他渲染内容
     */
    public function renderBottom($otherHTML = '')
    {
        $html = '';
        $html .= $otherHTML;
        $html .= '</body>
            </html>';
        echo $html;
    }

    /**
     * 渲染底部资源
     */
    public function renderBottomSource()
    {
        $html = <<<EOT

            <!--oiooer js-->
            <script type="text/javascript" src="/static/assets/admin/js/popper.min.js"></script>

            <!--bootstrap js-->
            <script src="/static/assets/admin/js/bootstrap-notify.min.js"></script>
            <script type="text/javascript" src="/static/assets/admin/js/bootstrap.min.js"></script>

            <!--cookie js-->
            <script type="text/javascript" src="/static/assets/admin/js/jquery.cookie.min.js"></script>

            <!--滚动条 js-->
            <script type="text/javascript" src="/static/assets/admin/js/perfect-scrollbar.min.js"></script>

            <!--tabs js-->
            <script type="text/javascript" src="/static/assets/admin/js/bootstrap-multitabs/multitabs.min.js"></script>
EOT;
        echo $html;
    }
}
